package xcu.lxj.nettychat.chat.service.adapter;

import org.springframework.stereotype.Service;
import xcu.lxj.nettychat.chat.domain.enums.WSRespTypeEnum;
import xcu.lxj.nettychat.chat.domain.vo.response.ChatMsgResp;
import xcu.lxj.nettychat.chat.domain.vo.response.WSBaseResp;
import xcu.lxj.nettychat.user.domain.vo.response.LoginSuccessResp;
import xcu.lxj.nettychat.user.domain.vo.response.ws.WSFriendApply;

/**
 * @Author XinJian Lei
 * @Date 2024/9/29 17:10
 * @Version 1.0
 */
@Service
public class WSAdapter {

    /**
     * 创建 新消息 其实就是 WSMessage
     * @see WSRespTypeEnum
     * @param msgResp
     * @return
     */
    public static WSBaseResp<ChatMsgResp> buildMsgSend(ChatMsgResp msgResp) {
        WSBaseResp<ChatMsgResp> wsBaseResp = new WSBaseResp<>();
        wsBaseResp.setType(WSRespTypeEnum.MESSAGE.getType());
        wsBaseResp.setData(msgResp);
        return wsBaseResp;
    }

    /**
     * 构建 验证token的resp
     * @return
     */
    public static WSBaseResp<LoginSuccessResp> buildWSInvalidateTokenResp() {
        WSBaseResp<LoginSuccessResp> wsBaseResp = new WSBaseResp<>();
        wsBaseResp.setType(WSRespTypeEnum.INVALIDATE_TOKEN.getType());
        return wsBaseResp;
    }
    public static WSBaseResp<WSFriendApply> buildApplySend(WSFriendApply resp) {
        WSBaseResp<WSFriendApply> wsBaseResp = new WSBaseResp<>();
        wsBaseResp.setType(WSRespTypeEnum.APPLY.getType());
        wsBaseResp.setData(resp);
        return wsBaseResp;
    }


}
